package com.wjy.demo.utils;

import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Component;


@Component
public class PageConvertUtils<R,T> {

    public PageInfo<T> convert(PageInfo<R> resourcesPage){

        PageInfo<T> pageResult = new PageInfo();

        pageResult.setPageSize(resourcesPage.getPageSize());
        pageResult.setPageNum(resourcesPage.getPageNum());
        pageResult.setTotal(resourcesPage.getTotal());

        pageResult.setIsLastPage(resourcesPage.isIsLastPage());
        pageResult.setHasNextPage(resourcesPage.isHasNextPage());
        pageResult.setIsFirstPage(resourcesPage.isIsFirstPage());

        pageResult.setPages(resourcesPage.getPages());
        pageResult.setPrePage(resourcesPage.getPrePage());
        pageResult.setNextPage(resourcesPage.getNextPage());

        pageResult.setStartRow(resourcesPage.getStartRow());
        pageResult.setEndRow(resourcesPage.getEndRow());

        return pageResult;
    }

}
